<?php 
//print_r( $_REQUEST );

include_once( ROOT . 'lib/vf.function.php'  );
include_once( ROOT . 'lib/biz.function.php'  );

check_user( 1 );

$id = ([$module_id]);

$fields = get_module_fields_by_id( $id );
check_form_input( get_meta_from_fields( $fields ) );

$cid = intval($_REQUEST['id']);

$_REQUEST['id'] = '__DY__where__' . $_REQUEST['id'];

if( is_admin() )
{
	$_REQUEST['dy_uid'] = '__DY__NULL';
	$_REQUEST['dy_nickname'] = '__DY__NULL';
}
else
	$_REQUEST['dy_uid'] = '__DY__where__' . $_SESSION['dy_uid'];


$_REQUEST['dy_tags']  = format_tags( $_REQUEST['dy_tags'] );

$bad_word = _conf( 'WEB_SITE_BAD_WORD_LIST' ); 
if( !empty( $bad_word ) )
{
	if( is_in_list( join( ' ' , $_REQUEST ) , $bad_word ) )
	{
		info_page( '<br/><h3><a href="javascript:history.back(1)">您发布的文字包含敏感信息，为了不给' . _conf( 'WEB_SITE_NAME' ) . '和您带来不必要的麻烦。请修正您的内容</a></h3>');
		exit;
	}
}

$pda = new pda( 'dy_content_' . $id );
if($pda->update())
{
	$tags = $_REQUEST['dy_tags'];
	//echo "tags = $tags" ; 
	if( !empty( $tags ) )
	{
		$cid = $_REQUEST['cid'];
		update_related_tags( $id , $cid , $tags );

		if( mysql_affected_rows() > 0 )
		{
			if( is_admin() )
				delete_tag( $id , $cid );
			else
				delete_tag( $id , $cid , $_SESSION['dy_uid'] );

			add_tag( $id , $cid , $tags );
		}
		
	}
		

	//info_page( '<a href="?u=([$dy_module_en_name])_list">数据已经成功保存,点击这里返回列表</a>' );
	forward( urldecode( $_REQUEST['forward'] ) );
	
	exit;
}

?>